<% layout('/layout/default.html', {title: '流程模型管理', libs: ['dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header">
			<div class="box-title">
				<i class="fa fa-cubes"></i> 流程模型管理
			</div>
			<div class="box-tools pull-right">
				<a href="#" class="btn btn-default" id="btnSearch" title="查询" ><i class="fa fa-filter"></i> 查询</a>
				<% if(hasPermi('act:model:edit')){ %>
					<a href="${ctxStatic}/modler/index.html#/processes" class="btn btn-default btnTool"  title="新增流程模型" data-type="layer"><i class="fa fa-plus"></i> 新增</a>
				<% } %>
			</div>
		</div>
		<div class="box-body">
			<form id="searchForm" action="${ctx}/act/model/listData" method="post" class="form-inline hide" >
			
				<div class="form-group">
					<label class="control-label">模型标识KEY：</label>
					<div class="control-inline">
						<input name="key" maxlength="100" class="form-control"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">模型名称：</label>
					<div class="control-inline">
						<input name="name" maxlength="100" class="form-control"/>
					</div>
				</div>
			
				<div class="form-group">
					<button type="submit" class="btn btn-primary btn-sm">查询</button>
					<button type="reset" class="btn btn-default btn-sm">重置</button>
				</div>
			</form>			
			<table id="dataGrid"></table>
			<div id="dataGridPage"></div>
		</div>
	</div>
</div>
<% } %>
<script>
//初始化DataGrid对象
$('#dataGrid').dataGrid({
	searchForm: $("#searchForm"),
	columnModel: [
		{header:'模型ID', name:'id', index:'a.id', width:90, align:"center" },
		{header:'模型标识KEY', name:'key', index:'a.model_key', width:100, align:"center" },
		{header:'模型名称', name:'name', index:'a.name', width:100, align:"center" },
		{header:'版本号', name:'version', index:'a.version', width:80, align:"center" , formatter:function(val, obj, row, act){
			return "V:" + val;
		}},
		{header:'创建时间', name:'created', index:'a.created', width:100, align:"center", formatter:"date" },
		{header:'最后更新时间', name:'lastUpdated', index:'a.last_updated', width:100, align:"center", formatter:"date" },
		{header:'操作', name:'actions', width:100, sortable:false, title:false, align:"center",formatter: function(val, obj, row, act){
			var actions = [];
			<% if(hasPermi('act:model:edit')){ %>
			
				actions.push('<a href="${ctxStatic}/modler/index.html#/editor/'+row.id+'" class="btnList" title="流程模型编辑" data-type="layer"><i class="fa fa-pencil"></i></a>&nbsp;');
				actions.push('<a href="${ctx}/act/model/deploy?id='+row.id+'" class="btnList" title="部署" data-formtitle="设置流程分类" data-type="form" data-formurl="${ctx}/act/model/choose/category"><i class="fa fa-bolt"></i></a>&nbsp;');
				actions.push('<a href="${flow}/app/rest/models/'+ row.id +'/bpmn20' + '" title="下载" ><i class="fa fa-download"></i></a>&nbsp;');
				actions.push('<a href="${ctx}/act/model/delete?id='+row.id+'" class="btnList" title="删除" data-confirm="确认要删除该模型吗？"><i class="fa fa-trash-o"></i></a>&nbsp;');
				
			<% } %>
			
			return actions.join('');
		}}
	],
	// 加载成功后执行事件
	ajaxSuccess: function(data){
		
	}
});

</script>